package cn.kust.apiuser.controller;

import cn.kust.microtourismcommon.pojo.dto.ResponseResult;
import cn.kust.microtourismcommon.pojo.response.TokenResponse;
import cn.kust.apiuser.service.ITokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author WY
 * @data 2022/7/21 10:23
 **/
@RestController
@RequestMapping("/api-user")
@Slf4j
public class TokenController {

    @Autowired
    private ITokenService iTokenService;

    @PostMapping("/token-refresh")
    public ResponseResult refreshToken(@RequestBody TokenResponse tokenResponse) {


        String refreshTokenSrc = tokenResponse.getRefreshToken();
        log.debug("===原token：" + refreshTokenSrc);

        return  iTokenService.refreshToken(refreshTokenSrc);
    }
}
